package com.chunlin.servlet;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

@WebServlet("/body")
public class BodyServlet extends HelloServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //设置好MIME类型和字符编码,避免网页乱码
        resp.setContentType("text/html;charset=utf-8");
        //让服务器返回一个html数据
        resp.getWriter().write("<div>你好世界</div>");
    }
}
